package com.ask.controller.user;

import com.ask.context.BaseContext;
import com.ask.entity.Dish;
import com.ask.result.PageResult;
import com.ask.result.Result;
import com.ask.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/recommend")
public class RecommendController {

    @Autowired
    private RecommendService recommendService;

    /**
     * 分压查询每日推荐
     * @param page
     * @param size
     * @return
     */
    @GetMapping
    public Result<PageResult> pageQueryDailyRecommendations(@RequestParam(defaultValue = "1") int page,
                                                      @RequestParam(defaultValue = "10") int size) {
        Long userId = 4L;
        return Result.success(recommendService.getDailyRecommendations(userId, page, size));
    }

    @GetMapping("/orderRec")
    public Result<List<Dish>> getOrderBasedRecommendations(Long userId) {
        return Result.success(recommendService.generateDailyRecommendations(userId));
    }
}
